var app = getApp(),
  a = app.requirejs("core"),
  b = app.requirejs("api/kjb");
Page({
  data: {
    show: false,
    loaded: false,
    page:1,
    list: []
  },

  onLoad: function (e) {
    a.setting();
    this.setData(e);
    this.getList();
  },
  
  getList: function () {
    var that = this,
      page = that.data.page;
    b.MyBargain(page,that, function (t) {
      that.setData(t)
    })
  },
  /**
     * 下拉刷新
     */
  onPullDownRefresh: function () {
    this.setData({
      list: [],
      page: 1,
      loaded: false
    })
    this.getList()
    wx.stopPullDownRefresh();
  },
  /**
   * 跳转至详情
   */
  url: function (e) {
    var data = a.pdata(e);
    if (data.goods_type == 1) {
      wx.navigateTo({
        url: '/yb_shop/pages/kanjia/discount_info/index?id=' + data.id+'&kj_stu=1'
      })
    }else{
      a.alert('活动已结束')
    }
  },
  /**
     *上拉加载
     */
  onReachBottom: function () {
    this.data.loaded || this.getList();
  }
})  